var RemoteMethods = new FileManager.RemoteMethods();

Plugin.FileManagerWindow = Ext.extend(Ext.app.Module, {

    init : function(){
        this.launcher = {
            text: Plugin.messages["FileManager.title"],
            iconCls:'db-icn-sm-computer',
            handler : this.createWindow,
            scope: this
        };    
    },

    createWindow : function(){
    
    	RemoteMethods.login(MyDesktop.currentSessionId,
			function (result,success,error) {
				if(success) {
					var desktop = this.app.getDesktop();
			        var fm = desktop.getWindow('file-manager');
			        if(!fm){			               
						fm = desktop.createWindow({id: 'file-manager',settings:{
							"CurrentView": result.CurrentView,
							"SingleUploadMode": result.SingleUploadMode,
							"UserName": result.UserName,
							"FirstName": result.FirstName
						}}, FileManager.FileManager);           
						fm.show();			
			        } else {
			            fm.show();  
			        }
				} else {
					alert(error);
				}
			},
			this
		);        
    }
});

Plugin.modules.push(new Plugin.FileManagerWindow());